home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
You can browse this item here: libregex.tex
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| LaTeX document text
| default
| |
99%
| file
| LaTeX document, ASCII text, with CR line terminators
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[CR]
| default (weak)
|
|
id metadata |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [R*ch] |
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 42 75 69 6c 74 2d 69 |\section|{Built-i|
|00000010| 6e 20 4d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |n Module| \sectco|
|00000020| 64 65 7b 72 65 67 65 78 | 7d 7d 0d 0d 5c 62 69 6d |de{regex|}}..\bim|
|00000030| 6f 64 69 6e 64 65 78 7b | 72 65 67 65 78 7d 0d 54 |odindex{|regex}.T|
|00000040| 68 69 73 20 6d 6f 64 75 | 6c 65 20 70 72 6f 76 69 |his modu|le provi|
|00000050| 64 65 73 20 72 65 67 75 | 6c 61 72 20 65 78 70 72 |des regu|lar expr|
|00000060| 65 73 73 69 6f 6e 20 6d | 61 74 63 68 69 6e 67 20 |ession m|atching |
|00000070| 6f 70 65 72 61 74 69 6f | 6e 73 20 73 69 6d 69 6c |operatio|ns simil|
|00000080| 61 72 20 74 6f 0d 74 68 | 6f 73 65 20 66 6f 75 6e |ar to.th|ose foun|
|00000090| 64 20 69 6e 20 45 6d 61 | 63 73 2e 20 20 49 74 20 |d in Ema|cs. It |
|000000a0| 69 73 20 61 6c 77 61 79 | 73 20 61 76 61 69 6c 61 |is alway|s availa|
|000000b0| 62 6c 65 2e 0d 0d 42 79 | 20 64 65 66 61 75 6c 74 |ble...By| default|
|000000c0| 20 74 68 65 20 70 61 74 | 74 65 72 6e 73 20 61 72 | the pat|terns ar|
|000000d0| 65 20 45 6d 61 63 73 2d | 73 74 79 6c 65 20 72 65 |e Emacs-|style re|
|000000e0| 67 75 6c 61 72 20 65 78 | 70 72 65 73 73 69 6f 6e |gular ex|pression|
|000000f0| 73 3b 20 74 68 65 72 65 | 20 69 73 0d 61 20 77 61 |s; there| is.a wa|
|00000100| 79 20 74 6f 20 63 68 61 | 6e 67 65 20 74 68 65 20 |y to cha|nge the |
|00000110| 73 79 6e 74 61 78 20 74 | 6f 20 6d 61 74 63 68 20 |syntax t|o match |
|00000120| 74 68 61 74 20 6f 66 20 | 73 65 76 65 72 61 6c 20 |that of |several |
|00000130| 77 65 6c 6c 2d 6b 6e 6f | 77 6e 0d 5c 55 4e 49 58 |well-kno|wn.\UNIX|
|00000140| 7b 7d 20 75 74 69 6c 69 | 74 69 65 73 2e 0d 0d 54 |{} utili|ties...T|
|00000150| 68 69 73 20 6d 6f 64 75 | 6c 65 20 69 73 20 38 2d |his modu|le is 8-|
|00000160| 62 69 74 20 63 6c 65 61 | 6e 3a 20 62 6f 74 68 20 |bit clea|n: both |
|00000170| 70 61 74 74 65 72 6e 73 | 20 61 6e 64 20 73 74 72 |patterns| and str|
|00000180| 69 6e 67 73 20 6d 61 79 | 20 63 6f 6e 74 61 69 6e |ings may| contain|
|00000190| 20 6e 75 6c 6c 0d 62 79 | 74 65 73 20 61 6e 64 20 | null.by|tes and |
|000001a0| 63 68 61 72 61 63 74 65 | 72 73 20 77 68 6f 73 65 |characte|rs whose|
|000001b0| 20 68 69 67 68 20 62 69 | 74 20 69 73 20 73 65 74 | high bi|t is set|
|000001c0| 2e 0d 0d 5c 73 74 72 6f | 6e 67 7b 50 6c 65 61 73 |...\stro|ng{Pleas|
|000001d0| 65 20 6e 6f 74 65 3a 7d | 20 54 68 65 72 65 20 69 |e note:}| There i|
|000001e0| 73 20 61 20 6c 69 74 74 | 6c 65 2d 6b 6e 6f 77 6e |s a litt|le-known|
|000001f0| 20 66 61 63 74 20 61 62 | 6f 75 74 20 50 79 74 68 | fact ab|out Pyth|
|00000200| 6f 6e 20 73 74 72 69 6e | 67 0d 6c 69 74 65 72 61 |on strin|g.litera|
|00000210| 6c 73 20 77 68 69 63 68 | 20 6d 65 61 6e 73 20 74 |ls which| means t|
|00000220| 68 61 74 20 79 6f 75 20 | 64 6f 6e 27 74 20 75 73 |hat you |don't us|
|00000230| 75 61 6c 6c 79 20 68 61 | 76 65 20 74 6f 20 77 6f |ually ha|ve to wo|
|00000240| 72 72 79 20 61 62 6f 75 | 74 0d 64 6f 75 62 6c 69 |rry abou|t.doubli|
|00000250| 6e 67 20 62 61 63 6b 73 | 6c 61 73 68 65 73 2c 20 |ng backs|lashes, |
|00000260| 65 76 65 6e 20 74 68 6f | 75 67 68 20 74 68 65 79 |even tho|ugh they|
|00000270| 20 61 72 65 20 75 73 65 | 64 20 74 6f 20 65 73 63 | are use|d to esc|
|00000280| 61 70 65 20 73 70 65 63 | 69 61 6c 0d 63 68 61 72 |ape spec|ial.char|
|00000290| 61 63 74 65 72 73 20 69 | 6e 20 73 74 72 69 6e 67 |acters i|n string|
|000002a0| 20 6c 69 74 65 72 61 6c | 73 20 61 73 20 77 65 6c | literal|s as wel|
|000002b0| 6c 20 61 73 20 69 6e 20 | 72 65 67 75 6c 61 72 20 |l as in |regular |
|000002c0| 65 78 70 72 65 73 73 69 | 6f 6e 73 2e 20 20 54 68 |expressi|ons. Th|
|000002d0| 69 73 0d 69 73 20 62 65 | 63 61 75 73 65 20 50 79 |is.is be|cause Py|
|000002e0| 74 68 6f 6e 20 64 6f 65 | 73 6e 27 74 20 72 65 6d |thon doe|sn't rem|
|000002f0| 6f 76 65 20 62 61 63 6b | 73 6c 61 73 68 65 73 20 |ove back|slashes |
|00000300| 66 72 6f 6d 20 73 74 72 | 69 6e 67 20 6c 69 74 65 |from str|ing lite|
|00000310| 72 61 6c 73 20 69 66 0d | 74 68 65 79 20 61 72 65 |rals if.|they are|
|00000320| 20 66 6f 6c 6c 6f 77 65 | 64 20 62 79 20 61 6e 20 | followe|d by an |
|00000330| 75 6e 72 65 63 6f 67 6e | 69 7a 65 64 20 65 73 63 |unrecogn|ized esc|
|00000340| 61 70 65 20 63 68 61 72 | 61 63 74 65 72 2e 0d 5c |ape char|acter..\|
|00000350| 65 6d 70 68 7b 48 6f 77 | 65 76 65 72 7d 2c 20 69 |emph{How|ever}, i|
|00000360| 66 20 79 6f 75 20 77 61 | 6e 74 20 74 6f 20 69 6e |f you wa|nt to in|
|00000370| 63 6c 75 64 65 20 61 20 | 6c 69 74 65 72 61 6c 20 |clude a |literal |
|00000380| 5c 64 66 6e 7b 62 61 63 | 6b 73 6c 61 73 68 7d 20 |\dfn{bac|kslash} |
|00000390| 69 6e 20 61 0d 72 65 67 | 75 6c 61 72 20 65 78 70 |in a.reg|ular exp|
|000003a0| 72 65 73 73 69 6f 6e 20 | 72 65 70 72 65 73 65 6e |ression |represen|
|000003b0| 74 65 64 20 61 73 20 61 | 20 73 74 72 69 6e 67 20 |ted as a| string |
|000003c0| 6c 69 74 65 72 61 6c 2c | 20 79 6f 75 20 68 61 76 |literal,| you hav|
|000003d0| 65 20 74 6f 0d 5c 65 6d | 70 68 7b 71 75 61 64 72 |e to.\em|ph{quadr|
|000003e0| 75 70 6c 65 7d 20 69 74 | 2e 20 20 45 2e 67 2e 20 |uple} it|. E.g. |
|000003f0| 20 74 6f 20 65 78 74 72 | 61 63 74 20 4c 61 54 65 | to extr|act LaTe|
|00000400| 58 20 5c 73 61 6d 70 7b | 5c 65 20 73 65 63 74 69 |X \samp{|\e secti|
|00000410| 6f 6e 5c 7b 7b 5c 72 6d | 0d 5c 6c 64 6f 74 73 7d |on\{{\rm|.\ldots}|
|00000420| 5c 7d 7d 20 68 65 61 64 | 65 72 73 20 66 72 6f 6d |\}} head|ers from|
|00000430| 20 61 20 64 6f 63 75 6d | 65 6e 74 2c 20 79 6f 75 | a docum|ent, you|
|00000440| 20 63 61 6e 20 75 73 65 | 20 74 68 69 73 20 70 61 | can use| this pa|
|00000450| 74 74 65 72 6e 3a 0d 5c | 63 6f 64 65 7b 27 5c 65 |ttern:.\|code{'\e|
|00000460| 20 5c 65 20 5c 65 5c 65 | 20 73 65 63 74 69 6f 6e | \e \e\e| section|
|00000470| 5c 7b 5c 65 20 28 2e 2a | 5c 65 20 29 5c 7d 27 7d |\{\e (.*|\e )\}'}|
|00000480| 2e 0d 0d 54 68 65 20 6d | 6f 64 75 6c 65 20 64 65 |...The m|odule de|
|00000490| 66 69 6e 65 73 20 74 68 | 65 73 65 20 66 75 6e 63 |fines th|ese func|
|000004a0| 74 69 6f 6e 73 2c 20 61 | 6e 64 20 61 6e 20 65 78 |tions, a|nd an ex|
|000004b0| 63 65 70 74 69 6f 6e 3a | 0d 0d 5c 72 65 6e 65 77 |ception:|..\renew|
|000004c0| 63 6f 6d 6d 61 6e 64 7b | 5c 69 6e 64 65 78 73 75 |command{|\indexsu|
|000004d0| 62 69 74 65 6d 7d 7b 28 | 69 6e 20 6d 6f 64 75 6c |bitem}{(|in modul|
|000004e0| 65 20 72 65 67 65 78 29 | 7d 0d 0d 5c 62 65 67 69 |e regex)|}..\begi|
|000004f0| 6e 7b 66 75 6e 63 64 65 | 73 63 7d 7b 6d 61 74 63 |n{funcde|sc}{matc|
|00000500| 68 7d 7b 70 61 74 74 65 | 72 6e 5c 2c 20 73 74 72 |h}{patte|rn\, str|
|00000510| 69 6e 67 7d 0d 20 20 52 | 65 74 75 72 6e 20 68 6f |ing}. R|eturn ho|
|00000520| 77 20 6d 61 6e 79 20 63 | 68 61 72 61 63 74 65 72 |w many c|haracter|
|00000530| 73 20 61 74 20 74 68 65 | 20 62 65 67 69 6e 6e 69 |s at the| beginni|
|00000540| 6e 67 20 6f 66 20 5c 76 | 61 72 7b 73 74 72 69 6e |ng of \v|ar{strin|
|00000550| 67 7d 20 6d 61 74 63 68 | 0d 20 20 74 68 65 20 72 |g} match|. the r|
|00000560| 65 67 75 6c 61 72 20 65 | 78 70 72 65 73 73 69 6f |egular e|xpressio|
|00000570| 6e 20 5c 76 61 72 7b 70 | 61 74 74 65 72 6e 7d 2e |n \var{p|attern}.|
|00000580| 20 20 52 65 74 75 72 6e | 20 5c 63 6f 64 65 7b 2d | Return| \code{-|
|00000590| 31 7d 20 69 66 20 74 68 | 65 0d 20 20 73 74 72 69 |1} if th|e. stri|
|000005a0| 6e 67 20 64 6f 65 73 20 | 6e 6f 74 20 6d 61 74 63 |ng does |not matc|
|000005b0| 68 20 74 68 65 20 70 61 | 74 74 65 72 6e 20 28 74 |h the pa|ttern (t|
|000005c0| 68 69 73 20 69 73 20 64 | 69 66 66 65 72 65 6e 74 |his is d|ifferent|
|000005d0| 20 66 72 6f 6d 20 61 0d | 20 20 7a 65 72 6f 2d 6c | from a.| zero-l|
|000005e0| 65 6e 67 74 68 20 6d 61 | 74 63 68 21 29 2e 0d 5c |ength ma|tch!)..\|
|000005f0| 65 6e 64 7b 66 75 6e 63 | 64 65 73 63 7d 0d 0d 5c |end{func|desc}..\|
|00000600| 62 65 67 69 6e 7b 66 75 | 6e 63 64 65 73 63 7d 7b |begin{fu|ncdesc}{|
|00000610| 73 65 61 72 63 68 7d 7b | 70 61 74 74 65 72 6e 5c |search}{|pattern\|
|00000620| 2c 20 73 74 72 69 6e 67 | 7d 0d 20 20 52 65 74 75 |, string|}. Retu|
|00000630| 72 6e 20 74 68 65 20 66 | 69 72 73 74 20 70 6f 73 |rn the f|irst pos|
|00000640| 69 74 69 6f 6e 20 69 6e | 20 5c 76 61 72 7b 73 74 |ition in| \var{st|
|00000650| 72 69 6e 67 7d 20 74 68 | 61 74 20 6d 61 74 63 68 |ring} th|at match|
|00000660| 65 73 20 74 68 65 20 72 | 65 67 75 6c 61 72 0d 20 |es the r|egular. |
|00000670| 20 65 78 70 72 65 73 73 | 69 6f 6e 20 5c 76 61 72 | express|ion \var|
|00000680| 7b 70 61 74 74 65 72 6e | 7d 2e 20 20 52 65 74 75 |{pattern|}. Retu|
|00000690| 72 6e 20 2d 31 20 69 66 | 20 6e 6f 20 70 6f 73 69 |rn -1 if| no posi|
|000006a0| 74 69 6f 6e 20 69 6e 20 | 74 68 65 20 73 74 72 69 |tion in |the stri|
|000006b0| 6e 67 0d 20 20 6d 61 74 | 63 68 65 73 20 74 68 65 |ng. mat|ches the|
|000006c0| 20 70 61 74 74 65 72 6e | 20 28 74 68 69 73 20 69 | pattern| (this i|
|000006d0| 73 20 64 69 66 66 65 72 | 65 6e 74 20 66 72 6f 6d |s differ|ent from|
|000006e0| 20 61 20 7a 65 72 6f 2d | 6c 65 6e 67 74 68 20 6d | a zero-|length m|
|000006f0| 61 74 63 68 0d 20 20 61 | 6e 79 77 68 65 72 65 21 |atch. a|nywhere!|
|00000700| 29 2e 0d 5c 65 6e 64 7b | 66 75 6e 63 64 65 73 63 |)..\end{|funcdesc|
|00000710| 7d 0d 0d 5c 62 65 67 69 | 6e 7b 66 75 6e 63 64 65 |}..\begi|n{funcde|
|00000720| 73 63 7d 7b 63 6f 6d 70 | 69 6c 65 7d 7b 70 61 74 |sc}{comp|ile}{pat|
|00000730| 74 65 72 6e 5c 6f 70 74 | 69 6f 6e 61 6c 7b 5c 2c |tern\opt|ional{\,|
|00000740| 20 74 72 61 6e 73 6c 61 | 74 65 7d 7d 0d 20 20 43 | transla|te}}. C|
|00000750| 6f 6d 70 69 6c 65 20 61 | 20 72 65 67 75 6c 61 72 |ompile a| regular|
|00000760| 20 65 78 70 72 65 73 73 | 69 6f 6e 20 70 61 74 74 | express|ion patt|
|00000770| 65 72 6e 20 69 6e 74 6f | 20 61 20 72 65 67 75 6c |ern into| a regul|
|00000780| 61 72 20 65 78 70 72 65 | 73 73 69 6f 6e 0d 20 20 |ar expre|ssion. |
|00000790| 6f 62 6a 65 63 74 2c 20 | 77 68 69 63 68 20 63 61 |object, |which ca|
|000007a0| 6e 20 62 65 20 75 73 65 | 64 20 66 6f 72 20 6d 61 |n be use|d for ma|
|000007b0| 74 63 68 69 6e 67 20 75 | 73 69 6e 67 20 69 74 73 |tching u|sing its|
|000007c0| 20 5c 63 6f 64 65 7b 6d | 61 74 63 68 7d 20 61 6e | \code{m|atch} an|
|000007d0| 64 0d 20 20 5c 63 6f 64 | 65 7b 73 65 61 72 63 68 |d. \cod|e{search|
|000007e0| 7d 20 6d 65 74 68 6f 64 | 73 2c 20 64 65 73 63 72 |} method|s, descr|
|000007f0| 69 62 65 64 20 62 65 6c | 6f 77 2e 20 20 54 68 65 |ibed bel|ow. The|
|00000800| 20 6f 70 74 69 6f 6e 61 | 6c 0d 20 20 5c 76 61 72 | optiona|l. \var|
|00000810| 7b 74 72 61 6e 73 6c 61 | 74 65 7d 2c 20 69 66 20 |{transla|te}, if |
|00000820| 70 72 65 73 65 6e 74 2c | 20 6d 75 73 74 20 62 65 |present,| must be|
|00000830| 20 61 20 32 35 36 2d 63 | 68 61 72 61 63 74 65 72 | a 256-c|haracter|
|00000840| 20 73 74 72 69 6e 67 0d | 20 20 69 6e 64 69 63 61 | string.| indica|
|00000850| 74 69 6e 67 20 68 6f 77 | 20 63 68 61 72 61 63 74 |ting how| charact|
|00000860| 65 72 73 20 28 62 6f 74 | 68 20 6f 66 20 74 68 65 |ers (bot|h of the|
|00000870| 20 70 61 74 74 65 72 6e | 20 61 6e 64 20 6f 66 20 | pattern| and of |
|00000880| 74 68 65 20 73 74 72 69 | 6e 67 73 20 74 6f 0d 20 |the stri|ngs to. |
|00000890| 20 62 65 20 6d 61 74 63 | 68 65 64 29 20 61 72 65 | be matc|hed) are|
|000008a0| 20 74 72 61 6e 73 6c 61 | 74 65 64 20 62 65 66 6f | transla|ted befo|
|000008b0| 72 65 20 63 6f 6d 70 61 | 72 69 6e 67 20 74 68 65 |re compa|ring the|
|000008c0| 6d 3b 20 74 68 65 20 5c | 63 6f 64 65 7b 69 7d 2d |m; the \|code{i}-|
|000008d0| 74 68 0d 20 20 65 6c 65 | 6d 65 6e 74 20 6f 66 20 |th. ele|ment of |
|000008e0| 74 68 65 20 73 74 72 69 | 6e 67 20 67 69 76 65 73 |the stri|ng gives|
|000008f0| 20 74 68 65 20 74 72 61 | 6e 73 6c 61 74 69 6f 6e | the tra|nslation|
|00000900| 20 66 6f 72 20 74 68 65 | 20 63 68 61 72 61 63 74 | for the| charact|
|00000910| 65 72 20 77 69 74 68 0d | 20 20 41 53 43 49 49 20 |er with.| ASCII |
|00000920| 63 6f 64 65 20 5c 63 6f | 64 65 7b 69 7d 2e 0d 0d |code \co|de{i}...|
|00000930| 20 20 54 68 65 20 73 65 | 71 75 65 6e 63 65 0d 0d | The se|quence..|
|00000940| 5c 62 63 6f 64 65 5c 62 | 65 67 69 6e 7b 76 65 72 |\bcode\b|egin{ver|
|00000950| 62 61 74 69 6d 7d 0d 70 | 72 6f 67 20 3d 20 72 65 |batim}.p|rog = re|
|00000960| 67 65 78 2e 63 6f 6d 70 | 69 6c 65 28 70 61 74 29 |gex.comp|ile(pat)|
|00000970| 0d 72 65 73 75 6c 74 20 | 3d 20 70 72 6f 67 2e 6d |.result |= prog.m|
|00000980| 61 74 63 68 28 73 74 72 | 29 0d 5c 65 6e 64 7b 76 |atch(str|).\end{v|
|00000990| 65 72 62 61 74 69 6d 7d | 5c 65 63 6f 64 65 0d 0d |erbatim}|\ecode..|
|000009a0| 69 73 20 65 71 75 69 76 | 61 6c 65 6e 74 20 74 6f |is equiv|alent to|
|000009b0| 0d 0d 5c 62 63 6f 64 65 | 5c 62 65 67 69 6e 7b 76 |..\bcode|\begin{v|
|000009c0| 65 72 62 61 74 69 6d 7d | 0d 72 65 73 75 6c 74 20 |erbatim}|.result |
|000009d0| 3d 20 72 65 67 65 78 2e | 6d 61 74 63 68 28 70 61 |= regex.|match(pa|
|000009e0| 74 2c 20 73 74 72 29 0d | 5c 65 6e 64 7b 76 65 72 |t, str).|\end{ver|
|000009f0| 62 61 74 69 6d 7d 5c 65 | 63 6f 64 65 0d 0d 62 75 |batim}\e|code..bu|
|00000a00| 74 20 74 68 65 20 76 65 | 72 73 69 6f 6e 20 75 73 |t the ve|rsion us|
|00000a10| 69 6e 67 20 5c 63 6f 64 | 65 7b 63 6f 6d 70 69 6c |ing \cod|e{compil|
|00000a20| 65 28 29 7d 20 69 73 20 | 6d 6f 72 65 20 65 66 66 |e()} is |more eff|
|00000a30| 69 63 69 65 6e 74 20 77 | 68 65 6e 20 6d 75 6c 74 |icient w|hen mult|
|00000a40| 69 70 6c 65 0d 72 65 67 | 75 6c 61 72 20 65 78 70 |iple.reg|ular exp|
|00000a50| 72 65 73 73 69 6f 6e 73 | 20 61 72 65 20 75 73 65 |ressions| are use|
|00000a60| 64 20 63 6f 6e 63 75 72 | 72 65 6e 74 6c 79 20 69 |d concur|rently i|
|00000a70| 6e 20 61 20 73 69 6e 67 | 6c 65 20 70 72 6f 67 72 |n a sing|le progr|
|00000a80| 61 6d 2e 20 20 28 54 68 | 65 0d 63 6f 6d 70 69 6c |am. (Th|e.compil|
|00000a90| 65 64 20 76 65 72 73 69 | 6f 6e 20 6f 66 20 74 68 |ed versi|on of th|
|00000aa0| 65 20 6c 61 73 74 20 70 | 61 74 74 65 72 6e 20 70 |e last p|attern p|
|00000ab0| 61 73 73 65 64 20 74 6f | 20 5c 63 6f 64 65 7b 72 |assed to| \code{r|
|00000ac0| 65 67 65 78 2e 6d 61 74 | 63 68 28 29 7d 20 6f 72 |egex.mat|ch()} or|
|00000ad0| 0d 5c 63 6f 64 65 7b 72 | 65 67 65 78 2e 73 65 61 |.\code{r|egex.sea|
|00000ae0| 72 63 68 28 29 7d 20 69 | 73 20 63 61 63 68 65 64 |rch()} i|s cached|
|00000af0| 2c 20 73 6f 20 70 72 6f | 67 72 61 6d 73 20 74 68 |, so pro|grams th|
|00000b00| 61 74 20 75 73 65 20 6f | 6e 6c 79 20 61 20 73 69 |at use o|nly a si|
|00000b10| 6e 67 6c 65 0d 72 65 67 | 75 6c 61 72 20 65 78 70 |ngle.reg|ular exp|
|00000b20| 72 65 73 73 69 6f 6e 20 | 61 74 20 61 20 74 69 6d |ression |at a tim|
|00000b30| 65 20 6e 65 65 64 6e 27 | 74 20 77 6f 72 72 79 20 |e needn'|t worry |
|00000b40| 61 62 6f 75 74 20 63 6f | 6d 70 69 6c 69 6e 67 20 |about co|mpiling |
|00000b50| 72 65 67 75 6c 61 72 0d | 65 78 70 72 65 73 73 69 |regular.|expressi|
|00000b60| 6f 6e 73 2e 29 0d 5c 65 | 6e 64 7b 66 75 6e 63 64 |ons.).\e|nd{funcd|
|00000b70| 65 73 63 7d 0d 0d 5c 62 | 65 67 69 6e 7b 66 75 6e |esc}..\b|egin{fun|
|00000b80| 63 64 65 73 63 7d 7b 73 | 65 74 5f 73 79 6e 74 61 |cdesc}{s|et_synta|
|00000b90| 78 7d 7b 66 6c 61 67 73 | 7d 0d 20 20 53 65 74 20 |x}{flags|}. Set |
|00000ba0| 74 68 65 20 73 79 6e 74 | 61 78 20 74 6f 20 62 65 |the synt|ax to be|
|00000bb0| 20 75 73 65 64 20 62 79 | 20 66 75 74 75 72 65 20 | used by| future |
|00000bc0| 63 61 6c 6c 73 20 74 6f | 20 5c 63 6f 64 65 7b 63 |calls to| \code{c|
|00000bd0| 6f 6d 70 69 6c 65 7d 2c | 0d 20 20 5c 63 6f 64 65 |ompile},|. \code|
|00000be0| 7b 6d 61 74 63 68 7d 20 | 61 6e 64 20 5c 63 6f 64 |{match} |and \cod|
|00000bf0| 65 7b 73 65 61 72 63 68 | 7d 2e 20 20 28 41 6c 72 |e{search|}. (Alr|
|00000c00| 65 61 64 79 20 63 6f 6d | 70 69 6c 65 64 20 65 78 |eady com|piled ex|
|00000c10| 70 72 65 73 73 69 6f 6e | 20 6f 62 6a 65 63 74 73 |pression| objects|
|00000c20| 0d 20 20 61 72 65 20 6e | 6f 74 20 61 66 66 65 63 |. are n|ot affec|
|00000c30| 74 65 64 2e 29 20 20 54 | 68 65 20 61 72 67 75 6d |ted.) T|he argum|
|00000c40| 65 6e 74 20 69 73 20 61 | 6e 20 69 6e 74 65 67 65 |ent is a|n intege|
|00000c50| 72 20 77 68 69 63 68 20 | 69 73 20 74 68 65 20 4f |r which |is the O|
|00000c60| 52 20 6f 66 0d 20 20 73 | 65 76 65 72 61 6c 20 66 |R of. s|everal f|
|00000c70| 6c 61 67 20 62 69 74 73 | 2e 20 20 54 68 65 20 72 |lag bits|. The r|
|00000c80| 65 74 75 72 6e 20 76 61 | 6c 75 65 20 69 73 20 74 |eturn va|lue is t|
|00000c90| 68 65 20 70 72 65 76 69 | 6f 75 73 20 76 61 6c 75 |he previ|ous valu|
|00000ca0| 65 20 6f 66 0d 20 20 74 | 68 65 20 73 79 6e 74 61 |e of. t|he synta|
|00000cb0| 78 20 66 6c 61 67 73 2e | 20 20 4e 61 6d 65 73 20 |x flags.| Names |
|00000cc0| 66 6f 72 20 74 68 65 20 | 66 6c 61 67 73 20 61 72 |for the |flags ar|
|00000cd0| 65 20 64 65 66 69 6e 65 | 64 20 69 6e 20 74 68 65 |e define|d in the|
|00000ce0| 20 73 74 61 6e 64 61 72 | 64 0d 20 20 6d 6f 64 75 | standar|d. modu|
|00000cf0| 6c 65 20 5c 63 6f 64 65 | 7b 72 65 67 65 78 5f 73 |le \code|{regex_s|
|00000d00| 79 6e 74 61 78 7d 3b 20 | 72 65 61 64 20 74 68 65 |yntax}; |read the|
|00000d10| 20 66 69 6c 65 20 5c 66 | 69 6c 65 7b 72 65 67 65 | file \f|ile{rege|
|00000d20| 78 5f 73 79 6e 74 61 78 | 2e 70 79 7d 20 66 6f 72 |x_syntax|.py} for|
|00000d30| 0d 20 20 6d 6f 72 65 20 | 69 6e 66 6f 72 6d 61 74 |. more |informat|
|00000d40| 69 6f 6e 2e 0d 5c 65 6e | 64 7b 66 75 6e 63 64 65 |ion..\en|d{funcde|
|00000d50| 73 63 7d 0d 0d 5c 62 65 | 67 69 6e 7b 66 75 6e 63 |sc}..\be|gin{func|
|00000d60| 64 65 73 63 7d 7b 73 79 | 6d 63 6f 6d 70 7d 7b 70 |desc}{sy|mcomp}{p|
|00000d70| 61 74 74 65 72 6e 5c 6f | 70 74 69 6f 6e 61 6c 7b |attern\o|ptional{|
|00000d80| 5c 2c 20 74 72 61 6e 73 | 6c 61 74 65 7d 7d 0d 54 |\, trans|late}}.T|
|00000d90| 68 69 73 20 69 73 20 6c | 69 6b 65 20 5c 63 6f 64 |his is l|ike \cod|
|00000da0| 65 7b 63 6f 6d 70 69 6c | 65 7d 2c 20 62 75 74 20 |e{compil|e}, but |
|00000db0| 73 75 70 70 6f 72 74 73 | 20 73 79 6d 62 6f 6c 69 |supports| symboli|
|00000dc0| 63 20 67 72 6f 75 70 20 | 6e 61 6d 65 73 3a 20 69 |c group |names: i|
|00000dd0| 66 20 61 0d 70 61 72 65 | 6e 74 68 65 73 65 73 2d |f a.pare|ntheses-|
|00000de0| 65 6e 63 6c 6f 73 65 64 | 20 67 72 6f 75 70 20 62 |enclosed| group b|
|00000df0| 65 67 69 6e 73 20 77 69 | 74 68 20 61 20 67 72 6f |egins wi|th a gro|
|00000e00| 75 70 20 6e 61 6d 65 20 | 69 6e 20 61 6e 67 75 6c |up name |in angul|
|00000e10| 61 72 0d 62 72 61 63 6b | 65 74 73 2c 20 65 2e 67 |ar.brack|ets, e.g|
|00000e20| 2e 20 5c 63 6f 64 65 7b | 27 5c 65 28 3c 69 64 3e |. \code{|'\e(<id>|
|00000e30| 5b 61 2d 7a 5d 5b 61 2d | 7a 30 2d 39 5d 2a 5c 65 |[a-z][a-|z0-9]*\e|
|00000e40| 29 27 7d 2c 20 74 68 65 | 20 67 72 6f 75 70 20 63 |)'}, the| group c|
|00000e50| 61 6e 0d 62 65 20 72 65 | 66 65 72 65 6e 63 65 64 |an.be re|ferenced|
|00000e60| 20 62 79 20 69 74 73 20 | 6e 61 6d 65 20 69 6e 20 | by its |name in |
|00000e70| 61 72 67 75 6d 65 6e 74 | 73 20 74 6f 20 74 68 65 |argument|s to the|
|00000e80| 20 5c 63 6f 64 65 7b 67 | 72 6f 75 70 7d 20 6d 65 | \code{g|roup} me|
|00000e90| 74 68 6f 64 20 6f 66 0d | 74 68 65 20 72 65 73 75 |thod of.|the resu|
|00000ea0| 6c 74 69 6e 67 20 63 6f | 6d 70 69 6c 65 64 20 72 |lting co|mpiled r|
|00000eb0| 65 67 75 6c 61 72 20 65 | 78 70 72 65 73 73 69 6f |egular e|xpressio|
|00000ec0| 6e 20 6f 62 6a 65 63 74 | 2c 20 6c 69 6b 65 20 74 |n object|, like t|
|00000ed0| 68 69 73 3a 0d 5c 63 6f | 64 65 7b 70 2e 67 72 6f |his:.\co|de{p.gro|
|00000ee0| 75 70 28 27 69 64 27 29 | 7d 2e 0d 5c 65 6e 64 7b |up('id')|}..\end{|
|00000ef0| 66 75 6e 63 64 65 73 63 | 7d 0d 0d 5c 62 65 67 69 |funcdesc|}..\begi|
|00000f00| 6e 7b 65 78 63 64 65 73 | 63 7d 7b 65 72 72 6f 72 |n{excdes|c}{error|
|00000f10| 7d 0d 20 20 45 78 63 65 | 70 74 69 6f 6e 20 72 61 |}. Exce|ption ra|
|00000f20| 69 73 65 64 20 77 68 65 | 6e 20 61 20 73 74 72 69 |ised whe|n a stri|
|00000f30| 6e 67 20 70 61 73 73 65 | 64 20 74 6f 20 6f 6e 65 |ng passe|d to one|
|00000f40| 20 6f 66 20 74 68 65 20 | 66 75 6e 63 74 69 6f 6e | of the |function|
|00000f50| 73 20 68 65 72 65 0d 20 | 20 69 73 20 6e 6f 74 20 |s here. | is not |
|00000f60| 61 20 76 61 6c 69 64 20 | 72 65 67 75 6c 61 72 20 |a valid |regular |
|00000f70| 65 78 70 72 65 73 73 69 | 6f 6e 20 28 65 2e 67 2e |expressi|on (e.g.|
|00000f80| 2c 20 75 6e 6d 61 74 63 | 68 65 64 20 70 61 72 65 |, unmatc|hed pare|
|00000f90| 6e 74 68 65 73 65 73 29 | 20 6f 72 0d 20 20 77 68 |ntheses)| or. wh|
|00000fa0| 65 6e 20 73 6f 6d 65 20 | 6f 74 68 65 72 20 65 72 |en some |other er|
|00000fb0| 72 6f 72 20 6f 63 63 75 | 72 73 20 64 75 72 69 6e |ror occu|rs durin|
|00000fc0| 67 20 63 6f 6d 70 69 6c | 61 74 69 6f 6e 20 6f 72 |g compil|ation or|
|00000fd0| 20 6d 61 74 63 68 69 6e | 67 2e 20 20 28 49 74 20 | matchin|g. (It |
|00000fe0| 69 73 0d 20 20 6e 65 76 | 65 72 20 61 6e 20 65 72 |is. nev|er an er|
|00000ff0| 72 6f 72 20 69 66 20 61 | 20 73 74 72 69 6e 67 20 |ror if a| string |
|00001000| 63 6f 6e 74 61 69 6e 73 | 20 6e 6f 20 6d 61 74 63 |contains| no matc|
|00001010| 68 20 66 6f 72 20 61 20 | 70 61 74 74 65 72 6e 2e |h for a |pattern.|
|00001020| 29 0d 5c 65 6e 64 7b 65 | 78 63 64 65 73 63 7d 0d |).\end{e|xcdesc}.|
|00001030| 0d 5c 62 65 67 69 6e 7b | 64 61 74 61 64 65 73 63 |.\begin{|datadesc|
|00001040| 7d 7b 63 61 73 65 66 6f | 6c 64 7d 0d 41 20 73 74 |}{casefo|ld}.A st|
|00001050| 72 69 6e 67 20 73 75 69 | 74 61 62 6c 65 20 74 6f |ring sui|table to|
|00001060| 20 70 61 73 73 20 61 73 | 20 5c 76 61 72 7b 74 72 | pass as| \var{tr|
|00001070| 61 6e 73 6c 61 74 65 7d | 20 61 72 67 75 6d 65 6e |anslate}| argumen|
|00001080| 74 20 74 6f 0d 5c 63 6f | 64 65 7b 63 6f 6d 70 69 |t to.\co|de{compi|
|00001090| 6c 65 7d 20 74 6f 20 6d | 61 70 20 61 6c 6c 20 75 |le} to m|ap all u|
|000010a0| 70 70 65 72 20 63 61 73 | 65 20 63 68 61 72 61 63 |pper cas|e charac|
|000010b0| 74 65 72 73 20 74 6f 20 | 74 68 65 69 72 20 6c 6f |ters to |their lo|
|000010c0| 77 65 72 63 61 73 65 0d | 65 71 75 69 76 61 6c 65 |wercase.|equivale|
|000010d0| 6e 74 73 2e 0d 5c 65 6e | 64 7b 64 61 74 61 64 65 |nts..\en|d{datade|
|000010e0| 73 63 7d 0d 0d 5c 6e 6f | 69 6e 64 65 6e 74 0d 43 |sc}..\no|indent.C|
|000010f0| 6f 6d 70 69 6c 65 64 20 | 72 65 67 75 6c 61 72 20 |ompiled |regular |
|00001100| 65 78 70 72 65 73 73 69 | 6f 6e 20 6f 62 6a 65 63 |expressi|on objec|
|00001110| 74 73 20 73 75 70 70 6f | 72 74 20 74 68 65 73 65 |ts suppo|rt these|
|00001120| 20 6d 65 74 68 6f 64 73 | 3a 0d 0d 5c 72 65 6e 65 | methods|:..\rene|
|00001130| 77 63 6f 6d 6d 61 6e 64 | 7b 5c 69 6e 64 65 78 73 |wcommand|{\indexs|
|00001140| 75 62 69 74 65 6d 7d 7b | 28 72 65 67 65 78 20 6d |ubitem}{|(regex m|
|00001150| 65 74 68 6f 64 29 7d 0d | 5c 62 65 67 69 6e 7b 66 |ethod)}.|\begin{f|
|00001160| 75 6e 63 64 65 73 63 7d | 7b 6d 61 74 63 68 7d 7b |uncdesc}|{match}{|
|00001170| 73 74 72 69 6e 67 5c 6f | 70 74 69 6f 6e 61 6c 7b |string\o|ptional{|
|00001180| 5c 2c 20 70 6f 73 7d 7d | 0d 20 20 52 65 74 75 72 |\, pos}}|. Retur|
|00001190| 6e 20 68 6f 77 20 6d 61 | 6e 79 20 63 68 61 72 61 |n how ma|ny chara|
|000011a0| 63 74 65 72 73 20 61 74 | 20 74 68 65 20 62 65 67 |cters at| the beg|
|000011b0| 69 6e 6e 69 6e 67 20 6f | 66 20 5c 76 61 72 7b 73 |inning o|f \var{s|
|000011c0| 74 72 69 6e 67 7d 20 6d | 61 74 63 68 0d 20 20 74 |tring} m|atch. t|
|000011d0| 68 65 20 63 6f 6d 70 69 | 6c 65 64 20 72 65 67 75 |he compi|led regu|
|000011e0| 6c 61 72 20 65 78 70 72 | 65 73 73 69 6f 6e 2e 20 |lar expr|ession. |
|000011f0| 20 52 65 74 75 72 6e 20 | 5c 63 6f 64 65 7b 2d 31 | Return |\code{-1|
|00001200| 7d 20 69 66 20 74 68 65 | 20 73 74 72 69 6e 67 0d |} if the| string.|
|00001210| 20 20 64 6f 65 73 20 6e | 6f 74 20 6d 61 74 63 68 | does n|ot match|
|00001220| 20 74 68 65 20 70 61 74 | 74 65 72 6e 20 28 74 68 | the pat|tern (th|
|00001230| 69 73 20 69 73 20 64 69 | 66 66 65 72 65 6e 74 20 |is is di|fferent |
|00001240| 66 72 6f 6d 20 61 20 7a | 65 72 6f 2d 6c 65 6e 67 |from a z|ero-leng|
|00001250| 74 68 0d 20 20 6d 61 74 | 63 68 21 29 2e 0d 20 20 |th. mat|ch!).. |
|00001260| 0d 20 20 54 68 65 20 6f | 70 74 69 6f 6e 61 6c 20 |. The o|ptional |
|00001270| 73 65 63 6f 6e 64 20 70 | 61 72 61 6d 65 74 65 72 |second p|arameter|
|00001280| 20 5c 76 61 72 7b 70 6f | 73 7d 20 67 69 76 65 73 | \var{po|s} gives|
|00001290| 20 61 6e 20 69 6e 64 65 | 78 20 69 6e 20 74 68 65 | an inde|x in the|
|000012a0| 20 73 74 72 69 6e 67 0d | 20 20 77 68 65 72 65 20 | string.| where |
|000012b0| 74 68 65 20 73 65 61 72 | 63 68 20 69 73 20 74 6f |the sear|ch is to|
|000012c0| 20 73 74 61 72 74 3b 20 | 69 74 20 64 65 66 61 75 | start; |it defau|
|000012d0| 6c 74 73 20 74 6f 20 5c | 63 6f 64 65 7b 30 7d 2e |lts to \|code{0}.|
|000012e0| 20 20 54 68 69 73 20 69 | 73 20 6e 6f 74 0d 20 20 | This i|s not. |
|000012f0| 63 6f 6d 70 6c 65 74 65 | 6c 79 20 65 71 75 69 76 |complete|ly equiv|
|00001300| 61 6c 65 6e 74 20 74 6f | 20 73 6c 69 63 69 6e 67 |alent to| slicing|
|00001310| 20 74 68 65 20 73 74 72 | 69 6e 67 3b 20 74 68 65 | the str|ing; the|
|00001320| 20 5c 63 6f 64 65 7b 27 | 5c 5e 27 7d 20 70 61 74 | \code{'|\^'} pat|
|00001330| 74 65 72 6e 0d 20 20 63 | 68 61 72 61 63 74 65 72 |tern. c|haracter|
|00001340| 20 6d 61 74 63 68 65 73 | 20 61 74 20 74 68 65 20 | matches| at the |
|00001350| 72 65 61 6c 20 62 65 67 | 69 6e 20 6f 66 20 74 68 |real beg|in of th|
|00001360| 65 20 73 74 72 69 6e 67 | 20 61 6e 64 20 61 74 20 |e string| and at |
|00001370| 70 6f 73 69 74 69 6f 6e | 73 0d 20 20 6a 75 73 74 |position|s. just|
|00001380| 20 61 66 74 65 72 20 61 | 20 6e 65 77 6c 69 6e 65 | after a| newline|
|00001390| 2c 20 6e 6f 74 20 6e 65 | 63 65 73 73 61 72 69 6c |, not ne|cessaril|
|000013a0| 79 20 61 74 20 74 68 65 | 20 69 6e 64 65 78 20 77 |y at the| index w|
|000013b0| 68 65 72 65 20 74 68 65 | 20 73 65 61 72 63 68 0d |here the| search.|
|000013c0| 20 20 69 73 20 74 6f 20 | 73 74 61 72 74 2e 0d 5c | is to |start..\|
|000013d0| 65 6e 64 7b 66 75 6e 63 | 64 65 73 63 7d 0d 0d 5c |end{func|desc}..\|
|000013e0| 62 65 67 69 6e 7b 66 75 | 6e 63 64 65 73 63 7d 7b |begin{fu|ncdesc}{|
|000013f0| 73 65 61 72 63 68 7d 7b | 73 74 72 69 6e 67 5c 6f |search}{|string\o|
|00001400| 70 74 69 6f 6e 61 6c 7b | 5c 2c 20 70 6f 73 7d 7d |ptional{|\, pos}}|
|00001410| 0d 20 20 52 65 74 75 72 | 6e 20 74 68 65 20 66 69 |. Retur|n the fi|
|00001420| 72 73 74 20 70 6f 73 69 | 74 69 6f 6e 20 69 6e 20 |rst posi|tion in |
|00001430| 5c 76 61 72 7b 73 74 72 | 69 6e 67 7d 20 74 68 61 |\var{str|ing} tha|
|00001440| 74 20 6d 61 74 63 68 65 | 73 20 74 68 65 20 72 65 |t matche|s the re|
|00001450| 67 75 6c 61 72 0d 20 20 | 65 78 70 72 65 73 73 69 |gular. |expressi|
|00001460| 6f 6e 20 5c 63 6f 64 65 | 7b 70 61 74 74 65 72 6e |on \code|{pattern|
|00001470| 7d 2e 20 20 52 65 74 75 | 72 6e 20 5c 63 6f 64 65 |}. Retu|rn \code|
|00001480| 7b 2d 31 7d 20 69 66 20 | 6e 6f 20 70 6f 73 69 74 |{-1} if |no posit|
|00001490| 69 6f 6e 20 69 6e 20 74 | 68 65 0d 20 20 73 74 72 |ion in t|he. str|
|000014a0| 69 6e 67 20 6d 61 74 63 | 68 65 73 20 74 68 65 20 |ing matc|hes the |
|000014b0| 70 61 74 74 65 72 6e 20 | 28 74 68 69 73 20 69 73 |pattern |(this is|
|000014c0| 20 64 69 66 66 65 72 65 | 6e 74 20 66 72 6f 6d 20 | differe|nt from |
|000014d0| 61 20 7a 65 72 6f 2d 6c | 65 6e 67 74 68 0d 20 20 |a zero-l|ength. |
|000014e0| 6d 61 74 63 68 20 61 6e | 79 77 68 65 72 65 21 29 |match an|ywhere!)|
|000014f0| 2e 0d 20 20 0d 20 20 54 | 68 65 20 6f 70 74 69 6f |.. . T|he optio|
|00001500| 6e 61 6c 20 73 65 63 6f | 6e 64 20 70 61 72 61 6d |nal seco|nd param|
|00001510| 65 74 65 72 20 68 61 73 | 20 74 68 65 20 73 61 6d |eter has| the sam|
|00001520| 65 20 6d 65 61 6e 69 6e | 67 20 61 73 20 66 6f 72 |e meanin|g as for|
|00001530| 20 74 68 65 0d 20 20 5c | 63 6f 64 65 7b 6d 61 74 | the. \|code{mat|
|00001540| 63 68 7d 20 6d 65 74 68 | 6f 64 2e 0d 5c 65 6e 64 |ch} meth|od..\end|
|00001550| 7b 66 75 6e 63 64 65 73 | 63 7d 0d 0d 5c 62 65 67 |{funcdes|c}..\beg|
|00001560| 69 6e 7b 66 75 6e 63 64 | 65 73 63 7d 7b 67 72 6f |in{funcd|esc}{gro|
|00001570| 75 70 7d 7b 69 6e 64 65 | 78 5c 2c 20 69 6e 64 65 |up}{inde|x\, inde|
|00001580| 78 5c 2c 20 2e 2e 2e 7d | 0d 54 68 69 73 20 6d 65 |x\, ...}|.This me|
|00001590| 74 68 6f 64 20 69 73 20 | 6f 6e 6c 79 20 76 61 6c |thod is |only val|
|000015a0| 69 64 20 77 68 65 6e 20 | 74 68 65 20 6c 61 73 74 |id when |the last|
|000015b0| 20 63 61 6c 6c 20 74 6f | 20 74 68 65 20 5c 63 6f | call to| the \co|
|000015c0| 64 65 7b 6d 61 74 63 68 | 7d 0d 6f 72 20 5c 63 6f |de{match|}.or \co|
|000015d0| 64 65 7b 73 65 61 72 63 | 68 7d 20 6d 65 74 68 6f |de{searc|h} metho|
|000015e0| 64 20 66 6f 75 6e 64 20 | 61 20 6d 61 74 63 68 2e |d found |a match.|
|000015f0| 20 20 49 74 20 72 65 74 | 75 72 6e 73 20 6f 6e 65 | It ret|urns one|
|00001600| 20 6f 72 20 6d 6f 72 65 | 0d 67 72 6f 75 70 73 20 | or more|.groups |
|00001610| 6f 66 20 74 68 65 20 6d | 61 74 63 68 2e 20 20 49 |of the m|atch. I|
|00001620| 66 20 74 68 65 72 65 20 | 69 73 20 61 20 73 69 6e |f there |is a sin|
|00001630| 67 6c 65 20 5c 76 61 72 | 7b 69 6e 64 65 78 7d 20 |gle \var|{index} |
|00001640| 61 72 67 75 6d 65 6e 74 | 2c 0d 74 68 65 20 72 65 |argument|,.the re|
|00001650| 73 75 6c 74 20 69 73 20 | 61 20 73 69 6e 67 6c 65 |sult is |a single|
|00001660| 20 73 74 72 69 6e 67 3b | 20 69 66 20 74 68 65 72 | string;| if ther|
|00001670| 65 20 61 72 65 20 6d 75 | 6c 74 69 70 6c 65 20 61 |e are mu|ltiple a|
|00001680| 72 67 75 6d 65 6e 74 73 | 2c 20 74 68 65 0d 72 65 |rguments|, the.re|
|00001690| 73 75 6c 74 20 69 73 20 | 61 20 74 75 70 6c 65 20 |sult is |a tuple |
|000016a0| 77 69 74 68 20 6f 6e 65 | 20 69 74 65 6d 20 70 65 |with one| item pe|
|000016b0| 72 20 61 72 67 75 6d 65 | 6e 74 2e 20 20 49 66 20 |r argume|nt. If |
|000016c0| 74 68 65 20 5c 76 61 72 | 7b 69 6e 64 65 78 7d 20 |the \var|{index} |
|000016d0| 69 73 0d 7a 65 72 6f 2c | 20 74 68 65 20 63 6f 72 |is.zero,| the cor|
|000016e0| 72 65 73 70 6f 6e 64 69 | 6e 67 20 72 65 74 75 72 |respondi|ng retur|
|000016f0| 6e 20 76 61 6c 75 65 20 | 69 73 20 74 68 65 20 65 |n value |is the e|
|00001700| 6e 74 69 72 65 20 6d 61 | 74 63 68 69 6e 67 20 73 |ntire ma|tching s|
|00001710| 74 72 69 6e 67 3b 20 69 | 66 0d 69 74 20 69 73 20 |tring; i|f.it is |
|00001720| 69 6e 20 74 68 65 20 69 | 6e 63 6c 75 73 69 76 65 |in the i|nclusive|
|00001730| 20 72 61 6e 67 65 20 5b | 31 2e 2e 39 39 5d 2c 20 | range [|1..99], |
|00001740| 69 74 20 69 73 20 74 68 | 65 20 73 74 72 69 6e 67 |it is th|e string|
|00001750| 20 6d 61 74 63 68 69 6e | 67 20 74 68 65 0d 74 68 | matchin|g the.th|
|00001760| 65 20 63 6f 72 72 65 73 | 70 6f 6e 64 69 6e 67 20 |e corres|ponding |
|00001770| 70 61 72 65 6e 74 68 65 | 73 69 7a 65 64 20 67 72 |parenthe|sized gr|
|00001780| 6f 75 70 20 28 75 73 69 | 6e 67 20 74 68 65 20 64 |oup (usi|ng the d|
|00001790| 65 66 61 75 6c 74 20 73 | 79 6e 74 61 78 2c 0d 67 |efault s|yntax,.g|
|000017a0| 72 6f 75 70 73 20 61 72 | 65 20 70 61 72 65 6e 74 |roups ar|e parent|
|000017b0| 68 65 73 69 7a 65 64 20 | 75 73 69 6e 67 20 5c 63 |hesized |using \c|
|000017c0| 6f 64 65 7b 5c 5c 28 7d | 20 61 6e 64 20 5c 63 6f |ode{\\(}| and \co|
|000017d0| 64 65 7b 5c 5c 29 7d 29 | 2e 20 20 49 66 20 6e 6f |de{\\)})|. If no|
|000017e0| 0d 73 75 63 68 20 67 72 | 6f 75 70 20 65 78 69 73 |.such gr|oup exis|
|000017f0| 74 73 2c 20 74 68 65 20 | 63 6f 72 72 65 73 70 6f |ts, the |correspo|
|00001800| 6e 64 69 6e 67 20 72 65 | 73 75 6c 74 20 69 73 20 |nding re|sult is |
|00001810| 5c 63 6f 64 65 7b 4e 6f | 6e 65 7d 2e 0d 0d 49 66 |\code{No|ne}...If|
|00001820| 20 74 68 65 20 72 65 67 | 75 6c 61 72 20 65 78 70 | the reg|ular exp|
|00001830| 72 65 73 73 69 6f 6e 20 | 77 61 73 20 63 6f 6d 70 |ression |was comp|
|00001840| 69 6c 65 64 20 62 79 20 | 5c 63 6f 64 65 7b 73 79 |iled by |\code{sy|
|00001850| 6d 63 6f 6d 70 7d 20 69 | 6e 73 74 65 61 64 20 6f |mcomp} i|nstead o|
|00001860| 66 0d 5c 63 6f 64 65 7b | 63 6f 6d 70 69 6c 65 7d |f.\code{|compile}|
|00001870| 2c 20 74 68 65 20 5c 76 | 61 72 7b 69 6e 64 65 78 |, the \v|ar{index|
|00001880| 7d 20 61 72 67 75 6d 65 | 6e 74 73 20 6d 61 79 20 |} argume|nts may |
|00001890| 61 6c 73 6f 20 62 65 20 | 73 74 72 69 6e 67 73 0d |also be |strings.|
|000018a0| 69 64 65 6e 74 69 66 79 | 69 6e 67 20 67 72 6f 75 |identify|ing grou|
|000018b0| 70 73 20 62 79 20 74 68 | 65 69 72 20 67 72 6f 75 |ps by th|eir grou|
|000018c0| 70 20 6e 61 6d 65 2e 0d | 5c 65 6e 64 7b 66 75 6e |p name..|\end{fun|
|000018d0| 63 64 65 73 63 7d 0d 0d | 5c 6e 6f 69 6e 64 65 6e |cdesc}..|\noinden|
|000018e0| 74 0d 43 6f 6d 70 69 6c | 65 64 20 72 65 67 75 6c |t.Compil|ed regul|
|000018f0| 61 72 20 65 78 70 72 65 | 73 73 69 6f 6e 73 20 73 |ar expre|ssions s|
|00001900| 75 70 70 6f 72 74 20 74 | 68 65 73 65 20 64 61 74 |upport t|hese dat|
|00001910| 61 20 61 74 74 72 69 62 | 75 74 65 73 3a 0d 0d 5c |a attrib|utes:..\|
|00001920| 72 65 6e 65 77 63 6f 6d | 6d 61 6e 64 7b 5c 69 6e |renewcom|mand{\in|
|00001930| 64 65 78 73 75 62 69 74 | 65 6d 7d 7b 28 72 65 67 |dexsubit|em}{(reg|
|00001940| 65 78 20 61 74 74 72 69 | 62 75 74 65 29 7d 0d 0d |ex attri|bute)}..|
|00001950| 5c 62 65 67 69 6e 7b 64 | 61 74 61 64 65 73 63 7d |\begin{d|atadesc}|
|00001960| 7b 72 65 67 73 7d 0d 57 | 68 65 6e 20 74 68 65 20 |{regs}.W|hen the |
|00001970| 6c 61 73 74 20 63 61 6c | 6c 20 74 6f 20 74 68 65 |last cal|l to the|
|00001980| 20 5c 63 6f 64 65 7b 6d | 61 74 63 68 7d 20 6f 72 | \code{m|atch} or|
|00001990| 20 5c 63 6f 64 65 7b 73 | 65 61 72 63 68 7d 20 6d | \code{s|earch} m|
|000019a0| 65 74 68 6f 64 20 66 6f | 75 6e 64 20 61 0d 6d 61 |ethod fo|und a.ma|
|000019b0| 74 63 68 2c 20 74 68 69 | 73 20 69 73 20 61 20 74 |tch, thi|s is a t|
|000019c0| 75 70 6c 65 20 6f 66 20 | 70 61 69 72 73 20 6f 66 |uple of |pairs of|
|000019d0| 20 69 6e 64 69 63 65 73 | 20 63 6f 72 72 65 73 70 | indices| corresp|
|000019e0| 6f 6e 64 69 6e 67 20 74 | 6f 20 74 68 65 0d 62 65 |onding t|o the.be|
|000019f0| 67 69 6e 6e 69 6e 67 20 | 61 6e 64 20 65 6e 64 20 |ginning |and end |
|00001a00| 6f 66 20 61 6c 6c 20 70 | 61 72 65 6e 74 68 65 73 |of all p|arenthes|
|00001a10| 69 7a 65 64 20 67 72 6f | 75 70 73 20 69 6e 20 74 |ized gro|ups in t|
|00001a20| 68 65 20 70 61 74 74 65 | 72 6e 2e 20 20 49 6e 64 |he patte|rn. Ind|
|00001a30| 69 63 65 73 0d 61 72 65 | 20 72 65 6c 61 74 69 76 |ices.are| relativ|
|00001a40| 65 20 74 6f 20 74 68 65 | 20 73 74 72 69 6e 67 20 |e to the| string |
|00001a50| 61 72 67 75 6d 65 6e 74 | 20 70 61 73 73 65 64 20 |argument| passed |
|00001a60| 74 6f 20 5c 63 6f 64 65 | 7b 6d 61 74 63 68 7d 20 |to \code|{match} |
|00001a70| 6f 72 0d 5c 63 6f 64 65 | 7b 73 65 61 72 63 68 7d |or.\code|{search}|
|00001a80| 2e 20 20 54 68 65 20 30 | 2d 74 68 20 74 75 70 6c |. The 0|-th tupl|
|00001a90| 65 20 67 69 76 65 73 20 | 74 68 65 20 62 65 67 69 |e gives |the begi|
|00001aa0| 6e 6e 69 6e 67 20 61 6e | 64 20 65 6e 64 20 6f 72 |nning an|d end or|
|00001ab0| 20 74 68 65 0d 77 68 6f | 6c 65 20 70 61 74 74 65 | the.who|le patte|
|00001ac0| 72 6e 2e 20 20 57 68 65 | 6e 20 74 68 65 20 6c 61 |rn. Whe|n the la|
|00001ad0| 73 74 20 6d 61 74 63 68 | 20 6f 72 20 73 65 61 72 |st match| or sear|
|00001ae0| 63 68 20 66 61 69 6c 65 | 64 2c 20 74 68 69 73 20 |ch faile|d, this |
|00001af0| 69 73 0d 5c 63 6f 64 65 | 7b 4e 6f 6e 65 7d 2e 0d |is.\code|{None}..|
|00001b00| 5c 65 6e 64 7b 64 61 74 | 61 64 65 73 63 7d 0d 0d |\end{dat|adesc}..|
|00001b10| 5c 62 65 67 69 6e 7b 64 | 61 74 61 64 65 73 63 7d |\begin{d|atadesc}|
|00001b20| 7b 6c 61 73 74 7d 0d 57 | 68 65 6e 20 74 68 65 20 |{last}.W|hen the |
|00001b30| 6c 61 73 74 20 63 61 6c | 6c 20 74 6f 20 74 68 65 |last cal|l to the|
|00001b40| 20 5c 63 6f 64 65 7b 6d | 61 74 63 68 7d 20 6f 72 | \code{m|atch} or|
|00001b50| 20 5c 63 6f 64 65 7b 73 | 65 61 72 63 68 7d 20 6d | \code{s|earch} m|
|00001b60| 65 74 68 6f 64 20 66 6f | 75 6e 64 20 61 0d 6d 61 |ethod fo|und a.ma|
|00001b70| 74 63 68 2c 20 74 68 69 | 73 20 69 73 20 74 68 65 |tch, thi|s is the|
|00001b80| 20 73 74 72 69 6e 67 20 | 61 72 67 75 6d 65 6e 74 | string |argument|
|00001b90| 20 70 61 73 73 65 64 20 | 74 6f 20 74 68 61 74 20 | passed |to that |
|00001ba0| 6d 65 74 68 6f 64 2e 20 | 20 57 68 65 6e 20 74 68 |method. | When th|
|00001bb0| 65 0d 6c 61 73 74 20 6d | 61 74 63 68 20 6f 72 20 |e.last m|atch or |
|00001bc0| 73 65 61 72 63 68 20 66 | 61 69 6c 65 64 2c 20 74 |search f|ailed, t|
|00001bd0| 68 69 73 20 69 73 20 5c | 63 6f 64 65 7b 4e 6f 6e |his is \|code{Non|
|00001be0| 65 7d 2e 0d 5c 65 6e 64 | 7b 64 61 74 61 64 65 73 |e}..\end|{datades|
|00001bf0| 63 7d 0d 0d 5c 62 65 67 | 69 6e 7b 64 61 74 61 64 |c}..\beg|in{datad|
|00001c00| 65 73 63 7d 7b 74 72 61 | 6e 73 6c 61 74 65 7d 0d |esc}{tra|nslate}.|
|00001c10| 54 68 69 73 20 69 73 20 | 74 68 65 20 76 61 6c 75 |This is |the valu|
|00001c20| 65 20 6f 66 20 74 68 65 | 20 5c 76 61 72 7b 74 72 |e of the| \var{tr|
|00001c30| 61 6e 73 6c 61 74 65 7d | 20 61 72 67 75 6d 65 6e |anslate}| argumen|
|00001c40| 74 20 74 6f 0d 5c 63 6f | 64 65 7b 72 65 67 65 78 |t to.\co|de{regex|
|00001c50| 2e 63 6f 6d 70 69 6c 65 | 7d 20 74 68 61 74 20 63 |.compile|} that c|
|00001c60| 72 65 61 74 65 64 20 74 | 68 69 73 20 72 65 67 75 |reated t|his regu|
|00001c70| 6c 61 72 20 65 78 70 72 | 65 73 73 69 6f 6e 20 6f |lar expr|ession o|
|00001c80| 62 6a 65 63 74 2e 20 20 | 49 66 0d 74 68 65 20 5c |bject. |If.the \|
|00001c90| 76 61 72 7b 74 72 61 6e | 73 6c 61 74 65 7d 20 61 |var{tran|slate} a|
|00001ca0| 72 67 75 6d 65 6e 74 20 | 77 61 73 20 6f 6d 69 74 |rgument |was omit|
|00001cb0| 74 65 64 20 69 6e 20 74 | 68 65 20 5c 63 6f 64 65 |ted in t|he \code|
|00001cc0| 7b 72 65 67 65 78 2e 63 | 6f 6d 70 69 6c 65 7d 0d |{regex.c|ompile}.|
|00001cd0| 63 61 6c 6c 2c 20 74 68 | 69 73 20 69 73 20 5c 63 |call, th|is is \c|
|00001ce0| 6f 64 65 7b 4e 6f 6e 65 | 7d 2e 0d 5c 65 6e 64 7b |ode{None|}..\end{|
|00001cf0| 64 61 74 61 64 65 73 63 | 7d 0d 0d 5c 62 65 67 69 |datadesc|}..\begi|
|00001d00| 6e 7b 64 61 74 61 64 65 | 73 63 7d 7b 67 69 76 65 |n{datade|sc}{give|
|00001d10| 6e 70 61 74 7d 0d 54 68 | 65 20 72 65 67 75 6c 61 |npat}.Th|e regula|
|00001d20| 72 20 65 78 70 72 65 73 | 73 69 6f 6e 20 70 61 74 |r expres|sion pat|
|00001d30| 74 65 72 6e 20 61 73 20 | 70 61 73 73 65 64 20 74 |tern as |passed t|
|00001d40| 6f 20 5c 63 6f 64 65 7b | 63 6f 6d 70 69 6c 65 7d |o \code{|compile}|
|00001d50| 20 6f 72 0d 5c 63 6f 64 | 65 7b 73 79 6d 63 6f 6d | or.\cod|e{symcom|
|00001d60| 70 7d 2e 0d 5c 65 6e 64 | 7b 64 61 74 61 64 65 73 |p}..\end|{datades|
|00001d70| 63 7d 0d 0d 5c 62 65 67 | 69 6e 7b 64 61 74 61 64 |c}..\beg|in{datad|
|00001d80| 65 73 63 7d 7b 72 65 61 | 6c 70 61 74 7d 0d 54 68 |esc}{rea|lpat}.Th|
|00001d90| 65 20 72 65 67 75 6c 61 | 72 20 65 78 70 72 65 73 |e regula|r expres|
|00001da0| 73 69 6f 6e 20 61 66 74 | 65 72 20 73 74 72 69 70 |sion aft|er strip|
|00001db0| 70 69 6e 67 20 74 68 65 | 20 67 72 6f 75 70 20 6e |ping the| group n|
|00001dc0| 61 6d 65 73 20 66 6f 72 | 20 72 65 67 75 6c 61 72 |ames for| regular|
|00001dd0| 0d 65 78 70 72 65 73 73 | 69 6f 6e 73 20 63 6f 6d |.express|ions com|
|00001de0| 70 69 6c 65 64 20 77 69 | 74 68 20 5c 63 6f 64 65 |piled wi|th \code|
|00001df0| 7b 73 79 6d 63 6f 6d 70 | 7d 2e 20 20 53 61 6d 65 |{symcomp|}. Same|
|00001e00| 20 61 73 20 5c 63 6f 64 | 65 7b 67 69 76 65 6e 70 | as \cod|e{givenp|
|00001e10| 61 74 7d 0d 6f 74 68 65 | 72 77 69 73 65 2e 0d 5c |at}.othe|rwise..\|
|00001e20| 65 6e 64 7b 64 61 74 61 | 64 65 73 63 7d 0d 0d 5c |end{data|desc}..\|
|00001e30| 62 65 67 69 6e 7b 64 61 | 74 61 64 65 73 63 7d 7b |begin{da|tadesc}{|
|00001e40| 67 72 6f 75 70 69 6e 64 | 65 78 7d 0d 41 20 64 69 |groupind|ex}.A di|
|00001e50| 63 74 69 6f 6e 61 72 79 | 20 67 69 76 69 6e 67 20 |ctionary| giving |
|00001e60| 74 68 65 20 6d 61 70 70 | 69 6e 67 20 66 72 6f 6d |the mapp|ing from|
|00001e70| 20 73 79 6d 62 6f 6c 69 | 63 20 67 72 6f 75 70 20 | symboli|c group |
|00001e80| 6e 61 6d 65 73 20 74 6f | 20 6e 75 6d 65 72 69 63 |names to| numeric|
|00001e90| 61 6c 0d 67 72 6f 75 70 | 20 69 6e 64 69 63 65 73 |al.group| indices|
|00001ea0| 20 66 6f 72 20 72 65 67 | 75 6c 61 72 20 65 78 70 | for reg|ular exp|
|00001eb0| 72 65 73 73 69 6f 6e 73 | 20 63 6f 6d 70 69 6c 65 |ressions| compile|
|00001ec0| 64 20 77 69 74 68 20 5c | 63 6f 64 65 7b 73 79 6d |d with \|code{sym|
|00001ed0| 63 6f 6d 70 7d 2e 0d 5c | 63 6f 64 65 7b 4e 6f 6e |comp}..\|code{Non|
|00001ee0| 65 7d 20 6f 74 68 65 72 | 77 69 73 65 2e 0d 5c 65 |e} other|wise..\e|
|00001ef0| 6e 64 7b 64 61 74 61 64 | 65 73 63 7d 0d |nd{datad|esc}. |
+--------+-------------------------+-------------------------+--------+--------+